package com.hbms.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hbms.common.annotation.Log;
import com.hbms.common.core.controller.BaseController;
import com.hbms.common.core.domain.AjaxResult;
import com.hbms.common.enums.BusinessType;
import com.hbms.business.domain.HotelbmsUserhotelbookings;
import com.hbms.business.service.IHotelbmsUserhotelbookingsService;
import com.hbms.common.utils.poi.ExcelUtil;
import com.hbms.common.core.page.TableDataInfo;

/**
 * 用户酒店订单Controller
 * 
 * @author zl
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/business/userhotelbookings")
public class HotelbmsUserhotelbookingsController extends BaseController
{
    @Autowired
    private IHotelbmsUserhotelbookingsService hotelbmsUserhotelbookingsService;

    /**
     * 查询用户酒店订单列表
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelbookings:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelbmsUserhotelbookings hotelbmsUserhotelbookings)
    {
        startPage();
        List<HotelbmsUserhotelbookings> list = hotelbmsUserhotelbookingsService.selectHotelbmsUserhotelbookingsList(hotelbmsUserhotelbookings);
        return getDataTable(list);
    }

    /**
     * 导出用户酒店订单列表
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelbookings:export')")
    @Log(title = "用户酒店订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelbmsUserhotelbookings hotelbmsUserhotelbookings)
    {
        List<HotelbmsUserhotelbookings> list = hotelbmsUserhotelbookingsService.selectHotelbmsUserhotelbookingsList(hotelbmsUserhotelbookings);
        ExcelUtil<HotelbmsUserhotelbookings> util = new ExcelUtil<HotelbmsUserhotelbookings>(HotelbmsUserhotelbookings.class);
        util.exportExcel(response, list, "用户酒店订单数据");
    }

    /**
     * 获取用户酒店订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelbookings:query')")
    @GetMapping(value = "/{userHotelBookingId}")
    public AjaxResult getInfo(@PathVariable("userHotelBookingId") Long userHotelBookingId)
    {
        return success(hotelbmsUserhotelbookingsService.selectHotelbmsUserhotelbookingsByUserHotelBookingId(userHotelBookingId));
    }

    /**
     * 新增用户酒店订单
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelbookings:add')")
    @Log(title = "用户酒店订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelbmsUserhotelbookings hotelbmsUserhotelbookings)
    {
        return toAjax(hotelbmsUserhotelbookingsService.insertHotelbmsUserhotelbookings(hotelbmsUserhotelbookings));
    }

    /**
     * 修改用户酒店订单
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelbookings:edit')")
    @Log(title = "用户酒店订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelbmsUserhotelbookings hotelbmsUserhotelbookings)
    {
        return toAjax(hotelbmsUserhotelbookingsService.updateHotelbmsUserhotelbookings(hotelbmsUserhotelbookings));
    }

    /**
     * 删除用户酒店订单
     */
    @PreAuthorize("@ss.hasPermi('business:userhotelbookings:remove')")
    @Log(title = "用户酒店订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userHotelBookingIds}")
    public AjaxResult remove(@PathVariable Long[] userHotelBookingIds)
    {
        return toAjax(hotelbmsUserhotelbookingsService.deleteHotelbmsUserhotelbookingsByUserHotelBookingIds(userHotelBookingIds));
    }
}
